﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Controls_MainArticleList : System.Web.UI.UserControl
{
    private string pageurl;
    public string PageUrl
    {
        get { return pageurl; }
        set { pageurl = value; }
    }

    int count = 10;
    public int Count
    {
        get { return count; }
        set { count = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            MRepBind();
        }
    }
    Cstudy.BLL.postClass post = new Cstudy.BLL.postClass();
    protected void MRep_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater rep = e.Item.FindControl("CRep") as Repeater;//找到里层的repeater对象
            DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
            int ClassID = Convert.ToInt32(rowv["CID"]); //获取填充子类的id 
            rep.DataSource = new Cstudy.BLL.Artcles().SelectArtcleByClassIDWithCount(ClassID, count);
            rep.DataBind();
        }
    }

    protected void MRepBind()
    {
        DataSet ds = new DataSet();
        ds = post.SelectPostClassOrderBy();
        MRep.DataSource = ds.Tables[0].DefaultView;
        MRep.DataBind();
    }
}